<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue.global.js"></script>
    <style>
      /* .demo {
            font-family: sans-serif;
            border: 1px solid #eee;
            border-radius: 2px;
            padding: 20px 30px;
            margin-top: 1em;
            margin-bottom: 40px;
            user-select: none;
            overflow-x: auto;
        } */
    </style>
  </head>

  <body>
    <div id="simplest-directive-example" class="demo">
      <!-- 自定义指令focus作用在元素input身上 -->
      <input v-focus />
    </div>

    <script>
      const app = Vue.createApp({
        directives: {
          focus: {
            // 指令的定义
            mounted(el) {
              el.focus();
            },
          },
        },
      });

      // 注册自定义指令v-focus
      // app.directive('focus', {
      //     // 目标元素被挂载 el目标元素
      //     mounted(el) {
      //         // 目标元素自动获得焦点
      //         el.focus()
      //     }
      // })

      app.mount("#simplest-directive-example");
    </script>
  </body>
</html>
